﻿export class UrlHelper {
    /**
     * The URL requested, before initial routing.
     */
    static readonly initialUrl = location.href;

    static getQueryParameters(): any {
        return document.location.search.replace(/(^\?)/, '').split("&").map(function (n) { 
            return n = n.split("="), this[n[0]] = n[1], this }.bind({}))[0];
    }
}


export function varToEnumStringVal(value: any, enumerator: any): string {
    let en: { [index: string]: any } = enumerator;

    if (!isNaN(parseInt(value, null))) {
        if (!en[value]) {
            const objValues = Object.keys(en).map(k => en[k]);
            const names = objValues.filter(v => typeof v === "string") as string[];
            return en[names[value]];
        }
    }
    let num = en[value];
    return en[num];
}